#pragma once

#ifndef MEASBASE_H
#define MEASBASE_H

#include <boost/shared_ptr.hpp>

#include "../interfaces.h"

typedef unsigned short MeasIndexType;

namespace measurement {

class MeasBase {
    boost::shared_ptr<MeasurementObject> mo;

    interfaces::LoggerIfc *loggingInterface;

protected:
    unsigned short measIndex;

    void add2Log(core::ErrorType type, std::string message) {
        loggingInterface->add(type, message);
    }

public:
    virtual void init() = 0;
    void setLoggerIfc(interfaces::LoggerIfc *ifc) {
        loggingInterface = ifc;
    }

    void setMOLink(boost::shared_ptr<MeasurementObject> mo) {
        this->mo = mo;
    }
    boost::shared_ptr<MeasurementObject> getMOLink() {
        return mo;
    }

    void setMeasIndex(unsigned short index) {
        measIndex = index;
    }
    unsigned short getMeasIndex() {
        return measIndex;
    }
};

class MeasReceiver: public MeasBase {
public:
    virtual void validateData(const core::DataPackage&) = 0;
};

class MeasDistributor: public MeasBase {
private:
    interfaces::DistributorIfc *distributorInterface;

public:
    void setDistributorIfc(interfaces::DistributorIfc *ifc) {
        distributorInterface = ifc;
    }

protected:
    void distribute(core::DataPackage *pkg) {
        distributorInterface->distribute(measIndex, pkg);
    }
};

}

#endif // MEASBASE_H
